home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj8307.arc
/
KSCOPE.BAS
< prev
next >
Wrap
BASIC Source File
|
1984-01-23
|
4KB
|
141 lines
1000 'File: KSCOPE.BAS
1010 'Auth: Thomas V. Hoffmann
1020 'Edit: TVH 18-April-83 6:00pm
1030 '
1040 DEFINT A-Z
1050 '----------
1060 'CGA Definitions
1070 '
1080 MODEREG = &H3D8: COLORREG = &H3D9 '-- CGA Control Registers
1090 MODESAVE = &H465: COLORSAVE = &H466 '-- BIOS Saves CGA Regs here
1100 CRTREG = &H3D4: CRTDATA = &H3D5 '-- 6845 CRT control regs
1110 HIRES=1: GRAPH=2: BW=4: VIDEO=8 '-- Mode register bits
1120 G640=16: BLINK=32 '-- ..
1130 '
1140 '----------
1150 ' Set MONO to 1 if both adapters installed
1160 ' 0 if color adapter only
1170 '
1180 MONO = 1
1190 '
1200 '----------
1210 ' Set F3=Load Picture, F4=Save Picture, F10=Exit
1220 '
1230 KEY ON: KEY (3) ON: KEY (4) ON: KEY (10) ON
1232 ON KEY(3) GOSUB 9300
1234 ON KEY(4) GOSUB 9400
1240 ON KEY(10) GOSUB 9900
1250 '
1260 '----------
1270 ' Initialize Color, Cycle Counter
1280 '
1290 PCOLOR=1
1300 TIMES=0
1310 INPUT "How many cycles per color change";MAXTIMES
1312 INPUT "Highest color number"; MAXCOLOR
1320 '----------
1330 'Setup Color Adapter for 160x100 Alpha Graphics
1340 '
1350 DEF SEG=0
1360 MODE = 0 '-- Turn off Video During Setup
1370 POKE MODESAVE,MODE: OUT MODEREG,MODE
1380 POKE COLORSAVE,0: OUT COLORREG,0
1390 '
1400 '-- Load New Parameters into 6845 CRT Controller
1410 FOR REG = 0 TO 11
1420 READ REGDATA
1430 OUT CRTREG, REG: OUT CRTDATA, REGDATA
1440 NEXT REG
1450 '
1460 '-- Set Mode for 80 Column Color and Enable
1470 MODE = HIRES + VIDEO
1480 POKE MODESAVE,MODE: OUT MODEREG,MODE
1490 '
1500 '-- Clear Screen: Character = &HDE, Attributes = 0
1510 DEF SEG = &HB800
1520 FOR CHAR = 0 TO 15998 STEP 2: POKE CHAR,&HDE: NEXT CHAR
1530 FOR ATTR = 1 TO 15999 STEP 2: POKE ATTR,0 : NEXT ATTR
1540 '
1550 '----------
1560 ' Generate Random Coordinates and Color
1570 ' and Reflect 8 Ways
1580 '
1590 BEEP
1600 WHILE 1 '-- Repeat until F10 struck
1610 TIMES = TIMES + 1
1620 IF TIMES > MAXTIMES THEN TIMES=0: PCOLOR=(PCOLOR+1) MOD (MAXCOLOR+1)
1630 X = RND*79: Y= RND*49
1640 GOSUB 4000
1650 IF X<79 THEN SWAP X,Y: GOSUB 4000
1660 WEND
4000 '----------
4010 ' Plot PCOLOR Symmetrically in each quadrant
4015 '
4020 X=159-X: GOSUB 5000
4030 Y= 99-Y: GOSUB 5000
4040 X=159-X: GOSUB 5000
4050 Y= 99-Y: GOSUB 5000
4060 RETURN
5000 '----------
5010 ' Plot PCOLOR at (X,Y)
5020 '
5030 PIXEL = X+(Y*160): PIXELADDR = (PIXEL AND &HFFFE) + 1
5040 NIBBLE = PIXEL MOD 2
5050 IF NIBBLE=0 THEN POKE PIXELADDR,(PEEK(PIXELADDR) AND &HF ) + PCOLOR * &H10
5060 IF NIBBLE=1 THEN POKE PIXELADDR,(PEEK(PIXELADDR) AND &HF0) + PCOLOR
5070 RETURN
7000 '----------
7010 ' Switch to Color/Graphics Display
7020 '
7030 DEF SEG=0: A=PEEK(&H410): POKE &H410,(A AND &HCF) OR &H20
7040 WIDTH 40: SCREEN 1: SCREEN 0: LOCATE ,,1,6,7
7050 RETURN
7060 '
7100 '----------
7110 ' Conditionally Switch to Monochrome Display
7120 '
7130 IF MONO <> 1 THEN GOSUB 7000: RETURN
7140 DEF SEG=0: A=PEEK(&H410): POKE &H410,(A OR &H30)
7150 WIDTH 80: LOCATE ,,1,12,13: SCREEN 0,0,0
7160 KEY ON
7170 RETURN
7180 '
8000 '----------
8010 ' Initial Data for 6845 (80x100 characters)
8020 '
8030 DATA 113 :'-- R0 Horizontal Total
8040 DATA 80 :'-- R1 Horizontal Displayed
8050 DATA 90 :'-- R2 Horizontal Sync Position
8060 DATA 10 :'-- R3 Horizontal Sync Width
8070 DATA 127 :'-- R4 Vertical Total
8080 DATA 6 :'-- R5 Vertical Adjust
8090 DATA 100 :'-- R6 Vertical Displayed
8100 DATA 112 :'-- R7 Vertical Sync Position
8110 DATA 2 :'-- R8 Interlace Mode (non-interlace)
8120 DATA 1 :'-- R9 Maximum Scan Line Address
8130 DATA 32 :'-- R10 Cursor Start (disables cursor display)
8140 DATA 0 :'-- R11 Cursor End
8150 '----------
9300 '----------
9310 ' F3 - Load Picture File
9320 '
9330 INPUT "Load from file: ", PIC$
9340 BLOAD PIC$,0
9345 INPUT "Press enter to continue...",JUNK$
9350 RETURN
9360 '
9400 '----------
9410 ' F4 - Save Picture File
9420 '
9430 INPUT "Save in file: ", PIC$
9440 BSAVE PIC$,0,16000
9445 INPUT "Press enter to continue...",JUNK$
9450 RETURN
9460 '
9900 '----------
9910 ' F10 - Exit
9920 '
9930 GOSUB 7100 '-- return to monochrome
9940 END '-- and quit
9999 END